<template>
  <template v-if="shouldShow">
    <slot />
  </template>
  <template v-if="!shouldShow && showDenyPage"> 无权限访问! </template>
</template>
<script setup lang="ts">
  import {computed} from 'vue'
  import storage from '@/utils/storage'
  const props = defineProps<{
    code:string | undefined,
    showDenyPage: {
      type:boolean,
      default:false
    } 
  }>()
  const shouldShow = computed(()=>{
    const powerCode: Array<string> = storage.get('power-code')
    if (props.code == undefined)
      return true;
      
    if (props.code && powerCode && powerCode.indexOf(props.code) >=0 ){
      return true;
    }
    return false;
  })
</script>
